#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int n, m;
int x, y;

vector<int> g[5010];
int indeg[5010];
int outdeg[5010];
int f[5010]; //表示到该节点有多少路

const int mod = 80112002;
int ans;

//食物链顶端出度为0

void topsort()
{
    queue<int> q;
    for (int i = 1; i <= n; i++)
    {
        if (indeg[i] == 0)
        {
            q.push(i); //入度为0的点入队
            f[i] = 1;  //初始化为1
        }
    }
    while (!q.empty()) //拓扑排序不需要判重
    {
        int u = q.front();
        q.pop();
        for (auto &v : g[u])
        {
            indeg[v]--;
            f[v] += f[u]; //记录数量
            f[v] %= mod;
            if (indeg[v] == 0)
            {
                if (outdeg[v] == 0)//如果到达终点
                {
                    ans += f[v];
                    ans %= mod;
                }
                q.push(v);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        cin >> x >> y;
        g[x].push_back(y);
        indeg[y]++;
        outdeg[x]++;
    }
    topsort();
    cout << ans << endl;
    system("pause");
    return 0;
}